package com.jellyfishumbrella.GL;

public class Ray {
	public static final double DEFAULT_RAY_LENGTH = 99999;
	public Vector3d	origin;
	public Vector3d direction;
	public Vector3d invDirection;
	public int sign[] = new int[3];
	
	public Ray(Vector3d o, Vector3d d){
		origin = o;
		direction = d;
		invDirection = new Vector3d(1.0/d.x, 1.0/d.y, 1.0/d.z);
		sign[0] = (invDirection.x < 0)? 1:0;
		sign[1] = (invDirection.y < 0)? 1:0;
		sign[2] = (invDirection.z < 0)? 1:0;
	}
	
	public Vector3d start(){
		return origin;
	}
	
	public Vector3d end(){
		Vector3d end = direction.clone();
		end.scale(DEFAULT_RAY_LENGTH);
		end.add(origin);
		return end;
	}
}
